<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String pid = request.getParameter("problem_id");
%>

<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="Bookmark" href="/favicon.ico">
		<link rel="Shortcut Icon" href="/favicon.ico" />
		<!--[if lt IE 9]>
<script type="text/javascript" src="jaj/html5shiv.js"></script>
<script type="text/javascript" src="jaj/respond.min.js"></script>
<![endif]-->
		<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
		<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
		<link rel="stylesheet" type="text/css" href="jaj/Hui-iconfont/1.0.8/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
		<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
		<!--[if IE 6]>
<script type="text/javascript" src="jaj/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
		<!--/meta 作为公共模版分离出去-->

		<title>添加员工</title>
		<meta name="keywords" content="H-ui.admin v3.1,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
		<meta name="description" content="H-ui.admin v3.1，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
	</head>

	<body onload="showTable()">
		<article class="page-container">
			<form action="" method="post" class="form form-horizontal" id="form-member-add1">
			    <input type="hidden" id="pid" name="pid" value="<%=pid%>">
				<div class="mt-20">
					<table class="table table-border table-bordered table-hover table-bg table-sort">
						<thead>
							<tr class="text-c">
								<!--<th width="5%"><input type="checkbox" name="" value=""></th>-->
								<th width="10%">ID</th>
								<th width="18%">姓名</th>
								<th width="18%">账号</th>
								<th width="18%">工分</th>
								<th width="18%">工作状态</th>
								<th width="18%">操作</th>
							</tr>
						</thead>
						<tbody id="tb">
							<!-- <tr class="text-c">
								<td><input type="checkbox" value="1" name=""></td>
								<td>1</td>
								<td>张三</td>
								<td>13000000000</td>
								<td>15</td>
								<td class="td-status"><span class="label label-success radius">空闲中</span></td>
								<td class="td-manage">
									<a style="text-decoration:none" onClick="member_stop(this,'10001')" href="javascript:;" title="选择"><i class="icon Hui-iconfont">&#xe610;</i> 选择</a>
									<a title="编辑" href="javascript:;" onclick="member_edit('编辑','member-add.html','4','','510')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
									<a style="text-decoration:none" class="ml-5" onClick="change_password('修改密码','change-password.html','10001','600','270')" href="javascript:;" title="修改密码"><i class="Hui-iconfont">&#xe63f;</i></a>
									<a title="删除" href="javascript:;" onclick="member_del(this,'1')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
								</td>
							</tr>
							<tr class="text-c">
								<td><input type="checkbox" value="1" name=""></td>
								<td>2</td>
								<td>李四</td>
								<td>130001212000</td>
								<td>15</td>
								<td class="td-status"><span class="label label-success radius">忙碌中</span></td>
								<td class="td-manage">
									<a style="text-decoration:none" onClick="member_stop(this,'10001')" href="javascript:;" title="选择"><i class="icon Hui-iconfont">&#xe610;</i> 选择</a>
									<a title="编辑" href="javascript:;" onclick="member_edit('编辑','member-add.html','4','','510')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
									<a style="text-decoration:none" class="ml-5" onClick="change_password('修改密码','change-password.html','10001','600','270')" href="javascript:;" title="修改密码"><i class="Hui-iconfont">&#xe63f;</i></a>
									<a title="删除" href="javascript:;" onclick="member_del(this,'1')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
								</td>
							</tr> -->
						</tbody>
					</table>
				</div>
			</form>
		</article>

		<!--_footer 作为公共模版分离出去-->
		<script type="text/javascript" src="jaj/jquery/1.9.1/jquery.min.js"></script>
		<script type="text/javascript" src="jaj/layer/2.4/layer.js"></script>
		<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
		<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script>
		<!--/_footer 作为公共模版分离出去-->

			<!--请在下方写此页面业务相关的脚本--><!-- 
			<script type="text/javascript" src="jaj/My97DatePicker/4.8/WdatePicker.js"></script> -->
		<script type="text/javascript" src="jaj/jquery.validation/1.14.0/jquery.validate.js"></script>
		<script type="text/javascript" src="jaj/jquery.validation/1.14.0/validate-methods.js"></script>
		<script type="text/javascript" src="jaj/jquery.validation/1.14.0/messages_zh.js"></script><!-- 
		<script type="text/javascript" src="jaj/datatables/1.10.0/jquery.dataTables.min.js"></script> -->
		<script type="text/javascript" src="jaj/laypage/1.2/laypage.js"></script>
		<script type="text/javascript">
			$(function() {
				$('.skin-minimal input').iCheck({
					checkboxClass: 'icheckbox-blue',
					radioClass: 'iradio-blue',
					increaseArea: '20%'
				});
				$(function() {
					$('.table-sort').dataTable({
						"aaSorting": [
							[1, "desc"]
						], //默认第几个排序
						"bStateSave": true, //状态保存
						"aoColumnDefs": [
							//{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
							{
								"orderable": false,
								"aTargets": [1,2,4,5]
							} // 制定列不参与排序
						]
					});

				});

				$("#form-member-add1").validate({
					rules: {
						username: {
							required: true,
							minlength: 2,
							maxlength: 16
						},
						sex: {
							required: true,
						},
						mobile: {
							required: true,
							isMobile: true,
						},
						email: {
							required: true,
							email: true,
						},
						uploadfile: {
							required: true,
						},

					},
					onkeyup: false,
					focusCleanup: true,
					success: "valid",
					submitHandler: function(form) {
						//$(form).ajaxSubmit();
						var index = parent.layer.getFrameIndex(window.name);
						//parent.$('.btn-refresh').click();
						parent.layer.close(index);
					}
				});
			});
			
			
			/*派遣员工*/
			function member_stop(obj, id) {
			    /* alert($("#pid").val());
			    alert(id+"ididididid"); */
				layer.confirm('确认派遣此员工吗？', function(index) {
					$.ajax({
						url: "ProblemServlet?method=ProblemSetWorkerId&problem_id="+$("#pid").val()+"&worker_id="+id,
						method: "post",
						dataType: "text",
						success: function(data) {
							if (data==1) {
								/* alert(data); */
								parent.location.href="picture-list2.jsp";
							}
						},
						error: function(data) {
							console.log(data.msg);
						},
					});
				});
			}

			/*用户-启用*/
			function member_start(obj, id) {
			
				layer.confirm('确认要启用吗？', function(index) {
					$.ajax({
						type: 'POST',
						url: '',
						dataType: 'json',
						success: function(data) {
							$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="Hui-iconfont">&#xe631;</i></a>');
							$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
							$(obj).remove();
							layer.msg('已启用!', {
								icon: 6,
								time: 1000
							});
						},
						error: function(data) {
							console.log(data.msg);
						},
					});
				});
			}
			
			function showTable(){
				$.ajax({
					url: "WorkerServlet?method=selectAllworker",
					dataType: "json",
					method: "post",
					success: function(data){
						for (var i = 0; i < data.length; i++) {
							$("#tb").html( $("#tb").html()+"<tr class='text-c'><td>"+data[i].worker_id+"</td><td>"+data[i].worker_name+"</td><td>"+
							data[i].worker_username+"</td><td>"+data[i].worker_score+"</td><td class=\"td-status\"><span class=\"label label-success radius\">"+
							data[i].worker_state+"</td><td class=\"td-manage\"><a style=\"text-decoration:none\" onClick=\"member_stop(this,'"+data[i].worker_id+"')\" href=\"javascript:;\" title=\"选择\"><i class=\"icon Hui-iconfont\">&#xe610;</i> 选择</a></td></tr>");
						}
					}
				});
			}
		</script>
	</body>

</html>
